package com.wwwarehouse.usercenter.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.wwwarehouse.usercenter.R;
import com.wwwarehouse.usercenter.bean.business_relationship.BRCFDTagsBean;
import com.wwwarehouse.usercenter.bean.business_relationship.BRCustomerFileDetailBean;

import java.util.ArrayList;

/**
 * @author : mundane
 * @time : 2017/9/20 14:14
 * @description :
 * @file : AuthorityDistributeRvAdapter.java
 */
public class BRCFCDTagsAdapter extends RecyclerView.Adapter<BRCFCDTagsAdapter.BRCFDTagsAdapterHolder> {

    private final int mRvHeight;
    private BRCFDTagsBean mDataList;
    private Context mContext;

    public interface OnItemClickListener {
        void onButtonClicked(int position);

    }

    private OnItemClickListener mOnItemClickListener;

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    public BRCFCDTagsAdapter(BRCFDTagsBean dataList, int height) {
        this.mDataList = dataList;
        mRvHeight = height;
    }

    @Override
    public BRCFDTagsAdapterHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        mContext = parent.getContext();
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_rv_authority_distribute, parent, false);
        return new BRCFDTagsAdapterHolder(view);
    }

    @Override
    public void onBindViewHolder(final BRCFDTagsAdapterHolder holder, final int position) {
        ViewGroup.LayoutParams params = holder.itemView.getLayoutParams();
        params.height = (int) (mRvHeight * 0.85 / 9);
        holder.itemView.setLayoutParams(params);
        holder.mBtn.setTextColor(mContext.getResources().getColor(R.color.common_color_c7_96999e));
        holder.mBtn.setBackground(mContext.getResources().getDrawable(R.drawable.shape_brcfcd_unclick));
        holder.mBtn.setEnabled(false);
        BRCFDTagsBean.ListBean listBean = mDataList.getList().get(position);
        holder.mBtn.setVisibility(View.VISIBLE);
        holder.mBtn.setText(listBean.getTagName());
    }

    @Override
    public int getItemCount() {
        return mDataList == null ? 0 : mDataList.getList().size();
    }

    static class BRCFDTagsAdapterHolder extends RecyclerView.ViewHolder {

        public Button mBtn;

        public BRCFDTagsAdapterHolder(View itemView) {
            super(itemView);
            mBtn = (Button) itemView.findViewById(R.id.btn);
        }
    }
}
